﻿using BaseDll;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UserData
{
    public static class PathHelper
    {
        private static string BasePath = "D:\\HY System\\";
        private static string csvBasePath = $"{BasePath}结果\\";
        public static string ImagePathDelete = $"{BasePath}图片\\";
        private static string logBasePath = $"{BasePath}日志\\";
        private static string manualBasePath = $"{BasePath}手动日志\\";
        private static string CheckBasePath = $"{BasePath}点检\\";
        private static string MesBasePath = $"{BasePath}Mes\\";
        private static string UV点检BasePath = $"{BasePath}点检\\";
        public static string str_Model = "AA";
        public static string str_Pici = "批次";

        public static string MotorCsvPath
        {
            get
            {
                string str_机型 = str_Model;
                string str_批次 = str_Pici;
                string path = $"{csvBasePath}{str_机型}\\{str_批次}\\{DateTime.Now.ToString("yyyy-MM-dd")}\\{DateTime.Now.ToString("yyyy-MM-dd")}_Motor.csv";
                if (!Directory.Exists(Directory.GetParent(path).FullName))
                {
                    Directory.CreateDirectory(Directory.GetParent(path).FullName);
                }
                return path;
            }
        }
        public static string TestResultCsvPath
        {
            get
            {
                string str_机型 = str_Model;
                string str_批次 = str_Pici;
                string path = $"{csvBasePath}\\{str_机型}\\{str_批次}\\{DateTime.Now.ToString("yyyy-MM-dd")}\\{DateTime.Now.ToString("yyyy-MM-dd")}_Result.csv";
                if (!Directory.Exists(Directory.GetParent(path).FullName))
                {
                    Directory.CreateDirectory(Directory.GetParent(path).FullName);
                }
                return path;
            }
        }
        public static string TestDispDataCsvPath
        {
            get
            {
                string str_机型 = str_Model;
                string str_批次 = str_Pici;
                string path = $"{csvBasePath}\\{str_机型}\\{str_批次}\\{DateTime.Now.ToString("yyyy-MM-dd")}\\{DateTime.Now.ToString("yyyy-MM-dd")}_DispData.csv";
                if (!Directory.Exists(Directory.GetParent(path).FullName))
                {
                    Directory.CreateDirectory(Directory.GetParent(path).FullName);
                }
                return path;
            }
        }
        public static string TestResultCsvOneDayPath
        {
            get
            {
                string path = $"{csvBasePath}\\_每日报表\\OneDay_{DateTime.Now.ToString("yyyy-MM-dd")}_Result.csv";
                if (!Directory.Exists(Directory.GetParent(path).FullName))
                {
                    Directory.CreateDirectory(Directory.GetParent(path).FullName);
                }
                return path;
            }
        }
        public static string TestResultCsvMesPath(string strSN)
        {
            string path = $"{MesBasePath}\\{strSN}.csv";
            if(File.Exists(path))
            {
                try
                {
                    File.Delete(path);
                }
                catch
                {
                }
            }
            try
            {
                if (!Directory.Exists(Directory.GetParent(path).FullName))
                {
                    Directory.CreateDirectory(Directory.GetParent(path).FullName);
                }
            }
            catch
            {

            }

            return path;
        }

        public static string UV点检_CsvPath
        {
            get
            {
                string path = $"{UV点检BasePath}\\{DateTime.Now.ToString("yyyy-MM-dd")}_UV点检.csv";
                if (!Directory.Exists(Directory.GetParent(path).FullName))
                {
                    Directory.CreateDirectory(Directory.GetParent(path).FullName);
                }
                return path;
            }
        }
        public static string TestTimeCsvPath
        {
            get
            {
                string str_机型 = str_Model;
                string str_批次 = str_Pici;
                string path = $"{csvBasePath}\\{str_机型}\\{str_批次}\\{DateTime.Now.ToString("yyyy-MM-dd")}\\{DateTime.Now.ToString("yyyy-MM-dd")}_Time.csv";
                if (!Directory.Exists(Directory.GetParent(path).FullName))
                {
                    Directory.CreateDirectory(Directory.GetParent(path).FullName);
                }
                return path;
            }
        }
        public static string ProductCsvPath
        {
            get
            {
                string str_机型 = str_Model;
                string str_批次 = str_Pici;
                string path = $"{csvBasePath}{str_机型}\\{str_批次}\\{DateTime.Now.ToString("yyyy-MM-dd")}\\{DateTime.Now.ToString("yyyy-MM-dd")}_Product.csv";
                if (!Directory.Exists(Directory.GetParent(path).FullName))
                {
                    Directory.CreateDirectory(Directory.GetParent(path).FullName);
                }
                return path;
            }
        }
        public static string MFCsvPath
        {
            get
            {
                string str_机型 = str_Model;
                string str_批次 = str_Pici;

                string path = $"{csvBasePath}{str_机型}\\{str_批次}\\{DateTime.Now.ToString("yyyy-MM-dd")}\\{DateTime.Now.ToString("yyyy-MM-dd")}_MF.csv";
                if (!Directory.Exists(Directory.GetParent(path).FullName))
                {
                    Directory.CreateDirectory(Directory.GetParent(path).FullName);
                }
                return path;
            }
        }
        public static string SFRResultCsvPath
        {
            get
            {
                string str_机型 = str_Model;
                string str_批次 = str_Pici;

                string path = $"{csvBasePath}{str_机型}\\{str_批次}\\{DateTime.Now.ToString("yyyy-MM-dd")}\\{DateTime.Now.ToString("yyyy-MM-dd")}_SFR.csv";
                if (!Directory.Exists(Directory.GetParent(path).FullName))
                {
                    Directory.CreateDirectory(Directory.GetParent(path).FullName);
                }
                return path;
            }
        }
        public static string LogPathAuto
        {
            get
            {
                string str_机型 = str_Model;
                string str_批次 = str_Pici;

                string path = $"{logBasePath}{str_机型}\\{str_批次}\\{DateTime.Now.ToString("yyyy-MM-dd")}\\{DateTime.Now.Hour}_Auto.txt";
                if (!Directory.Exists(Directory.GetParent(path).FullName))
                {
                    Directory.CreateDirectory(Directory.GetParent(path).FullName);
                }
                return path;
            }
        }
        public static string LogPathManual
        {
            get
            {
                string path = $"{manualBasePath}{DateTime.Now.ToString("yyyy-MM-dd")}_Manual.txt";
                if (!Directory.Exists(Directory.GetParent(path).FullName))
                {
                    Directory.CreateDirectory(Directory.GetParent(path).FullName);
                }
                return path;
            }
        }
        public static string ImageOKPath
        {
            get
            {
                string str_机型 = str_Model;
                string str_批次 = str_Pici;

                string path = $"{ImagePathDelete}{str_机型}\\{str_批次}\\{DateTime.Now.ToString("yyyy-MM-dd")}\\OK\\";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                return path;
            }
        }
        public static string ImageNGPath
        {
            get
            {
                string str_机型 = str_Model;
                string str_批次 = str_Pici;

                string path = $"{ImagePathDelete}{str_机型}\\{str_批次}\\{DateTime.Now.ToString("yyyy-MM-dd")}\\NG\\";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                return path;
            }
        }
        public static string TiltDataPath
        {
            get
            {
                string str_机型 = str_Model;
                string str_批次 = str_Pici;

                string path = $"{csvBasePath}\\{str_机型}\\{str_批次}\\{DateTime.Now.ToString("yyyy-MM-dd")}\\TiltData.txt";
                if (!Directory.Exists(Directory.GetParent(path).FullName))
                {
                    Directory.CreateDirectory(Directory.GetParent(path).FullName);
                }
                return path;
            }
        }


        public static string ImagePathWhite(bool bResult)
        {
            string path = bResult ? $"{ImageOKPath}\\白场\\" : $"{ImageNGPath}\\白场\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return path;
        }
        public static string ImagePathDispHigh(bool bResult)
        {
            string path = bResult ? $"{ImageOKPath}\\胶高\\" : $"{ImageNGPath}\\胶高\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return path;
        }
        public static string ImagePathProAAThroughFocus(bool bResult)
        {
            string path = bResult ? $"{ImageOKPath}\\ProAAThroughFocus\\" : $"{ImageNGPath}\\ProAAThroughFocus\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return path;
        }

        public static string ImagePathFindcenter(bool bResult)
        {
            string path = bResult ? $"{ImageOKPath}\\FindCenter\\" : $"{ImageNGPath}\\FindCenter\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return path;
        }
        public static string ImagePathThroughFocus(bool bResult)
        {
            string path = bResult ? $"{ImageOKPath}\\ThroughFocus\\" : $"{ImageNGPath}\\ThroughFocus\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return path;
        }
        public static string ImagePathSFRResult(bool bResult)
        {

            string path = bResult ? $"{ImageOKPath}\\ThroughFocusSFR\\" : $"{ImageNGPath}\\ThroughFocusSFR\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return path;
        }

        public static string ProcessSFRResult(string strSn)
        {

            string str_机型 = str_Model;
            string str_批次 = str_Pici;

            string path = $"{ImagePathDelete}{str_机型}\\{str_批次}\\{DateTime.Now.ToString("yyyy-MM-dd")}\\SFR过程数据\\strSn\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return path;
        }
        public static string ImagePathCheck(bool bResult)
        {
            string path = bResult ? $"{ImageOKPath}\\Check\\" : $"{ImageNGPath}\\Check\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return path;
        }
        public static string ImagePathChart(bool bResult)
        {
            string path = bResult ? $"{ImageOKPath}\\Chart\\" : $"{ImageNGPath}\\Chart\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return path;
        }
        public static string ImagePathProduct(bool bResult)
        {
            string path = bResult ? $"{ImageOKPath}\\成品\\" : $"{ImageNGPath}\\成品\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return path;
        }
        public static string ImagePathBeforeDisp(bool bResult)
        {
            string path = bResult ? $"{ImageOKPath}\\点胶前\\" : $"{ImageNGPath}\\点胶前\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return path;
        }
        public static string ImagePathAfterDisp(bool bResult)
        {
            string path = bResult ? $"{ImageOKPath}\\点胶后\\" : $"{ImageNGPath}\\点胶后\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return path;
        }
        public static string ImagePathPlasma(bool bResult)
        {
            string path = bResult ? $"{ImageOKPath}\\Plasma\\" : $"{ImageNGPath}\\Plasma\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return path;
        }
        public static string ImagePathMFFail(bool bResult)
        {
            string path = bResult ? $"{ImageOKPath}\\MFFail\\" : $"{ImageNGPath}\\MFFail\\";
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return path;
        }


    }
}
